//
//  EvaluationView.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/11/23.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "EvaluationView.h"

@implementation EvaluationView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        for (int i = 0; i < 4; i++) {
            UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake((kWidth/4-64)/2+kWidth/4*i, (kHeight-22)/2, 64, 22)];
            [self addSubview:btn];
            [btn addTarget: self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
            btn.tag = i;
            
            NSArray *titles = @[@"全部",@"好评",@"中评",@"差评"];
            btn.layer.masksToBounds = YES;
            btn.layer.cornerRadius = 22/2;
            
            [btn setTitle:titles[i] forState:UIControlStateNormal];
            if (i == 0) {
                [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                btn.titleLabel.font = [UIFont systemFontOfSize:14];
            }else {
                [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                btn.titleLabel.font = [UIFont systemFontOfSize:11];
            }
            if (i == 0||i == 1||i == 2) {
                [btn setBackgroundColor:[UIColor colorWithRed:251/255.0 green:225/255.0 blue:195/255.0 alpha:1]];
            
            }else {
                [btn setBackgroundColor:[UIColor colorWithRed:232/255.0 green:232/255.0 blue:232/255.0 alpha:1]];
            }
        }
    }
    return self;
}
-(void)clickBtn:(UIButton *)clickBtn
{
    if ([self.delegate respondsToSelector:@selector(EvaluationView:withBtn:)]) {
        [self.delegate EvaluationView:self withBtn:clickBtn];
    }
}
@end
